<?php
/**
 * 《编号管理》实现类
 *
 * @author 孙晓晔
 * @version $Id: Code.class.php 1035 2010-03-26 05:24:59Z sunxy $
 */
require_once(dirname(__FILE__) . '/InfoUtil.class.php');

class Sql extends InfoUtil {

	function __construct() {
		$request['update'] = '$Date: 2009/02/16 07:36:07 $';
		$request['revision'] = '$Revision: 1.1 $';

		parent::__construct($request);
	}

	function pretreat($controller) {
		parent::pretreat($controller);
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function find($controller, $request) {
		$this->pretreat($controller);
		
		global $cfg;
		$dsn = array();
		while (list($k, $v) = each($cfg["mysql"])) {
			$dsn[$k] = $k;
		}
		
		$controller->assign_by_ref('dsn_option', $dsn);

		$controller->display($request, 'info/sql/find');
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function findPost($controller, $request) {
		$dsn = $request['dsn'];
		$sql = $request['sql'];
		
		$db = newdb($dsn);
		$result = $db->query($sql);
		
		$controller->assign_by_ref('result', $db->fetch_all($result));
		
		$controller->display($request, 'info/sql/list');
		return true;
	}
}
?>